<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>输入年和月份，求该月有多少天</title>
    </head>
    <body>
        <script>
            // 输入年和月份，求该月有多少天
            
            var year = Number(prompt('请输入年份'));
            var month = Number(prompt('请输入月份'));

            switch (month) {
                case 1:
                case 3:
                case 5:
                case 7: 
                case 8: 
                case 10: 
                case 12:
                    alert('这个月有31天');
                    break;
                case 4: 
                case 6: 
                case 9: 
                case 11: 
                    alert('这个月有30天');
                    break;
                case 2: 
                    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                        alert('这个月有29天');
                    } else {
                        alert('这个月有28天');
                    }
                    break;
                default: 
                alert('你输入的月份有误');
            }
        </script>
    </body>
</html>